package com.back.service.impl;

import cn.hutool.core.util.StrUtil;
import com.back.exception.BusinessException;
import com.back.exception.ErrorCode;
import com.back.mapper.SceneLandmarkMapper;
import com.back.model.entity.SceneLandmark;
import com.back.service.SceneLandmarkService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @description 针对表【SceneLandmark(地标表)】的数据库操作Service实现
 * @createDate 2024-01-01 00:00:00
 */
@Service
@Slf4j
public class SceneLandmarkServiceImpl extends ServiceImpl<SceneLandmarkMapper, SceneLandmark>
        implements SceneLandmarkService {

    @Override
    public List<SceneLandmark> getLandmarksBySceneId(String sceneId) {
        if (StrUtil.isBlank(sceneId)) {
            throw new BusinessException(ErrorCode.PARAMS_ERROR, "场景ID不能为空");
        }
        QueryWrapper<SceneLandmark> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("sceneId", sceneId);
        queryWrapper.orderByAsc("landmarkId");
        return this.list(queryWrapper);
    }

    @Override
    public SceneLandmark getLandmarkById(String landmarkId) {
        if (StrUtil.isBlank(landmarkId)) {
            throw new BusinessException(ErrorCode.PARAMS_ERROR, "地标ID不能为空");
        }
        return this.getById(landmarkId);
    }
}